<template> 
  <div>
    <img
      class="user-poster"
      src="https://img.yzcdn.cn/public_files/2017/10/23/8690bb321356070e0b8c4404d087f8fd.png"
    />
    <van-row class="user-links">
      <van-col span="6">
        <van-icon name="pending-payment" />
        待付款
      </van-col>
      <van-col span="6">
        <van-icon name="records" />
        待接单
      </van-col>
      <van-col span="6">
        <van-icon name="tosend" />
        待发货
      </van-col>
      <van-col span="6">
        <van-icon name="logistics" />
        已发货
      </van-col>
    </van-row>

    <van-cell-group class="user-group">
      <van-cell icon="records" title="全部订单" is-link to="/test" />
    </van-cell-group>

    <van-cell-group>
      <van-cell icon="points" title="我的积分" @click="myCase" is-link/>  
      <van-cell icon="photo-o" title="文件上传" @click="toFile" is-link/>  
      <van-cell icon="photo-o" title="Excel操作"  to="/excelOpt" is-link/>  
      <van-cell icon="share-o" title="退出登录"  @click="btnConfirm" is-link/> 
    </van-cell-group>
  </div>
</template>

<script lang="ts" setup> 
import { onMounted } from 'vue'; 
import { Dialog,Toast } from "vant" 
import router from '@/router/index'  
import store from '@/store/index'   

onMounted(() => { 
  Toast.loading({
        message: '加载中...',
        type: "loading",
  }); 
  setTimeout(() => {
    Toast.clear()
  }, 100); 
})

const toFile = () => {
  router.push({ name: "file" });
}

const myCase = () => {
  Dialog({ message: 'Dialog 组件是以函数形式提供的，如果项目中使用 unplugin-vue-components 插件来自动引入组件样式，则无法正确识别 Dialog 组件，因此需要手动引入 Dialog 组件的样式：', confirmButtonColor:'#1989fa;'
    });
}

const btnConfirm = () => {
  Dialog.confirm({
    title: '退出登录',
    message:
      '是否确定退出',
  }).then(() => {
    store.dispatch('LogOut').then((res) => {
      router.push({ name: "login" });
    }).catch((error) => {
      Toast(error);
     });

  }).catch(() => { });
}
</script>

<style lang="scss">
.van-dialog__confirm {
  background: #1989fa !important;

  .van-button__text {
    color: #eee;
  }
}
.user {
  &-poster {
    width: 100%;
    height: 53vw;
    display: block;
  }

  &-group {
    margin-bottom: 15px;
  }

  &-links {
    padding: 15px 0;
    font-size: 12px;
    text-align: center; 
    .van-icon {
      display: block;
      font-size: 24px;
    }
  }
}
</style>
